<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:bm="http://localhost:8080/customTags">

    <rich:popupPanel id="editServicePanel" autosized="true" width="450" modal="true">
        <f:facet name="header">
            <h:outputText value="Edit Current Service" />
        </f:facet>

        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('editServicePanel')}.hide(); return false;">
                <h:graphicImage value="/images/modal/close.png" id="hidelink" styleClass="hidelink" style="border:0" />
            </h:outputLink>
        </f:facet>
            <h:form id="EditServiceForm">
                <h:panelGrid columns="1" id="serviceDetail">
                    <a4j:outputPanel ajaxRendered="true">
                        <h:panelGrid columns="3" id="grid">
                            <h:inputHidden id="id" value="#{serviceController.service.id}" />
                            <h:outputText value="Name" />
                            <h:inputText id="name" value="#{serviceController.service.name}" />
                            <rich:message for="name" style="color:red" />
                            <h:outputText id="description" value="Description" />
                            <h:inputText value="#{serviceController.service.description}" />
                            <h:message for="description" style="color:red" />
                            <h:outputText value="Stock Price" />
                            <h:inputText id="stockPrice" value="#{serviceController.service.stockPrice}"
                                         label="Stock Price" immediate="true" />
                            <h:message for="stockPrice" style="color:red" />
                            <h:outputText id="retailPrice" value="Retail Price" />
                            <h:inputText value="#{serviceController.service.retailPrice}"
                                         label="Retail Price" immediate="true" />
                            <h:message for="retailPrice" style="color:red" />
                            <h:outputText value="Credit Price" />
                            <h:inputText id="creditPrice"
                                         value="#{serviceController.service.creditPrice}" label="Credit Price"
                                         immediate="true" />
                            <h:message for="creditPrice" style="color:red" />
                            <h:outputText value="Default Category" />
                            <h:selectOneMenu id="category"
                                             value="#{serviceController.service.category}"
                                             label="Default Category">
                                <f:selectItems value="#{categories.list}" />
                            </h:selectOneMenu>
                            <h:message for="category" style="color:red" />
                        </h:panelGrid>
                    </a4j:outputPanel>
                    <a4j:commandButton value="Save" action="#{serviceController.update}"
                                       reRender="name,description,stockPrice,creditPrice,retailPrice,category"
                                       oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editServicePanel')}.hide();" />
                </h:panelGrid>
            </h:form>
    </rich:popupPanel>
</ui:composition>